package com.noble.meether.ui.vip.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.noble.meether.R;
import com.noble.library.image.ImageLoader;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewAdapter;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewHolder;
import com.noble.meether.ui.vip.bean.Privilege;

/**
 * 特权列表
 */
public class PrivilegeAdapter extends BaseRecyclerViewAdapter<Privilege> {

    private Context mContext;

    public PrivilegeAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.item_privilege_vip};//钻石item布局
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return super.onCreateViewHolder(parent, viewType);
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, int position) {
        MyViewHolder vh = new MyViewHolder(viewHolder);
        final Privilege info = getItem(position);
        vh.tv_remark.setText(info.getRemark());
        ImageLoader.loadCenterCrop(mContext, info.getImg(), vh.iv_icon);
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }

    class MyViewHolder {
        ImageView iv_icon;
        TextView tv_remark;

        public MyViewHolder(BaseRecyclerViewHolder convertView) {
            initView(convertView);
        }

        private void initView(BaseRecyclerViewHolder convertView) {
            iv_icon = convertView.findViewById(R.id.iv_icon);
            tv_remark = convertView.findViewById(R.id.tv_remark);
        }
    }
}